﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using nplJobsCommon.Common;
using nplJobsDAL.Insert;
using nplJobsDAL.Delete;

namespace nplJobsBLL.ProcessJob
{

    public class ProcessJobEntry : IBusinessLogic
    {
        public string CheckUnique;
        public int LastJobID = 0;

        public ProcessJobEntry()
        {
        }
        public Job Job { get; set; }
      
        public void invoke()
        {
            InsertJob insertJob = new InsertJob();
            insertJob.Job = this.Job;
            insertJob.Insert();
            LastJobID = insertJob.lastJobID;
            this.CheckUnique = insertJob.checkUnique;
        }

        public void Update()
        {
            InsertJob updateJob = new InsertJob();
            updateJob.Job = this.Job;
            updateJob.Update();
            LastJobID = updateJob.lastJobID;
            this.CheckUnique = updateJob.checkUnique;
        }

        public void InsertJobLocationWithin(long JobId, int DivisionId, int DistrictId, int CityId)
        {
            InsertJobLocationWithin insertJobLocationWithin = new InsertJobLocationWithin();
            insertJobLocationWithin.JobId = JobId;
            insertJobLocationWithin.DivisionId = DivisionId;
            insertJobLocationWithin.DistrictId = DistrictId;
            insertJobLocationWithin.CityId = CityId;
            insertJobLocationWithin.Insert();
        }

        public void InsertJobLocationOutside(long JobId, int CountryId, string CityName)
        {
            InsertJobLocationOutside insertJobLocationOutside = new InsertJobLocationOutside();
            insertJobLocationOutside.JobId = JobId;
            insertJobLocationOutside.CountryId = CountryId;
            insertJobLocationOutside.CityName = CityName;
            insertJobLocationOutside.Insert();
        }

        public void DeleteJobLocationWithin(long JobId)
        {
            DeleteJobLocationWithin deleteJobLocationWithin = new DeleteJobLocationWithin();
            deleteJobLocationWithin.JobId = JobId;
            deleteJobLocationWithin.Delete();
        }
    }
  }

